<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>API usage - CKEditor Sample</title>
	<meta content="text/html; charset=utf-8" http-equiv="content-type" />
	<script type="text/javascript" src="../ckeditor.js"></script>
	<script src="sample.js" type="text/javascript"></script>
	<link href="sample.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript">
	//<![CDATA[

// The instanceReady event is fired when an instance of CKEditor has finished
// its initialization.
CKEDITOR.on( 'instanceReady', function( ev )
{
	// Show the editor name and description in the browser status bar.
	document.getElementById( 'eMessage' ).innerHTML = '<p>Instance "' + ev.editor.name + '" loaded.<\/p>';

	// Show this sample buttons.
	document.getElementById( 'eButtons' ).style.visibility = '';
});

function InsertHTML()
{
	// Get the editor instance that we want to interact with.
	var oEditor = CKEDITOR.instances.editor1;
	var value = document.getElementById( 'plainArea' ).value;

	// Check the active editing mode.
	if ( oEditor.mode == 'wysiwyg' )
	{
		// Insert the desired HTML.
		oEditor.insertHtml( value );
	}
	else
		alert( 'You must be on WYSIWYG mode!' );
}

function SetContents()
{
	// Get the editor instance that we want to interact with.
	var oEditor = CKEDITOR.instances.editor1;
	var value = document.getElementById( 'plainArea' ).value;

	// Set the editor contents (replace the actual one).
	oEditor.setData( value );
}

function GetContents()
{
	// Get the editor instance that we want to interact with.
	var oEditor = CKEDITOR.instances.editor1;

	// Get the editor contents
	alert( oEditor.getData() );
}

function ExecuteCommand(commandName)
{
	// Get the editor instance that we want to interact with.
	var oEditor = CKEDITOR.instances.editor1;

	// Check the active editing mode.
	if ( oEditor.mode == 'wysiwyg' )
	{
		// Execute the command.
		oEditor.execCommand( commandName );
	}
	else
		alert( 'You must be on WYSIWYG mode!' );
}

function CheckDirty()
{
	// Get the editor instance that we want to interact with.
	var oEditor = CKEDITOR.instances.editor1;
	alert( oEditor.checkDirty() );
}

function ResetDirty()
{
	// Get the editor instance that we want to interact with.
	var oEditor = CKEDITOR.instances.editor1;
	oEditor.resetDirty();
	alert( 'The "IsDirty" status has been reset' );
}

function field(){
    this.field_kind="";
    this.field_name="";
    this.field_title="";
    this.field_size="";
    this.field_length="";
    this.field_readonly="";
    this.field_notnull="";
    this.field_showallow="";
    this.field_dropdown="";
}

var confData=new field()[3];

/**
 * 指定下拉式選單的值
 * @parameter:objSelect--要控制的select object
 *            value--要指定的值
 * @call events:
 * @call to:
 */
function fc_assign_select_value(objSelect,value){
  for(i=0;i<objSelect.options.length;i++){
    if(objSelect.options[i].value==value){
      objSelect.options[i].selected=true;
      break;
    }
  }
}

function Field_onchange(field){
    var confDetail=null;

    if(field.value=='flow_num'){
        confDetail=confData[0];
    }
    else if(field.value=='app_empno'){
        confDetail=confData[1];
    }
    else{
        confDetail=confData[2];
    }
alert(confDetail.kind);
        fc_assign_select_value(document.getElementById("field_kind"),confDetail.kind);
        //alert(123);
        document.getElementById("field_name").value=confDetail.name;
        //alert(567);
        document.getElementById("field_title").value=confDetail[2];
        document.getElementById("field_size").value=confDetail[3];
        document.getElementById("field_length").value=confDetail[4];
        document.getElementById("field_readonly").checked=(confDetail[5]=='Y');
        document.getElementById("field_notnull").checked=(confDetail[6]=='Y');
        document.getElementById("field_showallow").checked=(confDetail[7]=='Y');
        document.getElementById("field_dropdown").value=confDetail[8];
}

function evt_save_onclick(){
    var confDetail=new Array();

    confDetail[0]=document.getElementById("field_kind").value;
    confDetail[1]=document.getElementById("field_name").value;
    confDetail[2]=document.getElementById("field_title").value;
    confDetail[3]=document.getElementById("field_size").value;
    confDetail[4]=document.getElementById("field_length").value;
    confDetail[5]=document.getElementById("field_readonly").value;
    confDetail[6]=document.getElementById("field_notnull").value;
    confDetail[7]=document.getElementById("field_showallow").value;
    confDetail[8]=document.getElementById("field_dropdown").value;

    if(field.value=='flow_num'){
        confData[0]=confDetail;
    }
    else if(field.value=='app_empno'){
        confData[1]=confDetail;
    }
    else{
        confData[2]=confDetail;
    }
}
	//]]>
	</script>

</head>
<body>

	<!--h1>
		CKEditor Sample
	</h1>
	< This <div> holds alert messages to be display in the sample page. -->
	<div id="alerts">
		<noscript>
			<p>
				<strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
				support, like yours, you should still see the contents (HTML data) and you should
				be able to edit it normally, without a rich editor interface.
			</p>
		</noscript>
	</div>
	<form action="sample_posteddata.php" method="post">
		<!--p>
			This sample shows how to use the CKeditor JavaScript API to interact with the editor
			at runtime.</p-->
		<textarea cols="80" id="editor1" name="editor1" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>

		<script type="text/javascript">
		//<![CDATA[
			// Replace the <textarea id="editor1"> with an CKEditor instance.
			var editor = CKEDITOR.replace( 'editor1',{fullPage : true} );
		//]]>
		</script>

		<div id="eMessage">
		</div>
    <table>
        <tr>
            <td>
                <select name="fieldlist" size="10" onchange="Field_onchange(this)">
                    <option value="flow_num">flow_num</option>
                    <option value="app_empno">app_empno</option>
                    <option value="app_date_time">app_date_time</option>
                </select>
            </td>
            <td>
                <table>
                    <tr>
                        <td>
                            欄位型態：
                            <select id="field_kind" name="field_kind">
                                <option value="textbox">TextBox</option>
                                <option value="hidden">Hidden</option>
                                <option value="Dropdown">DropDown</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span id="setField" >
                                欄位名稱：<input type="text" size="10" id="field_name" name="field_name"></input><br/>
                                欄位標題：<input type="text" size="10" id="field_title" name="field_title"></input><br/>
                                欄位大小：<input type="text" size="3" id="field_size" name="field_size"></input><br/>
                                欄位長度：<input type="text" size="3" id="field_length" name="field_length"></input><br/>
                                唯讀：<input type="checkbox" id="field_readonly" name="field_readonly" value="Y"></input><br/>
                                必填：<input type="checkbox" id="field_notnull" name="field_notnull" value="Y"></input><br/>
                                顯示：<input type="checkbox" id="field_showallow" name="field_showallow" value="Y"></input><br/>
                                下拉選單值：<input type="text" size="30" id="field_dropdown" name="field_dropdown"></input><br/>
                            </span>
                            <input type="button" value="Save" onclick="evt_save_onclick()"></input>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    
		<div id="eButtons" >
			<input onclick="InsertHTML();" type="button" value="Insert HTML" />
			<input onclick="SetContents();" type="button" value="Set Editor Contents" />
			<input onclick="GetContents();" type="button" value="Get Editor Contents (XHTML)" />
			<br />
			<textarea cols="80" id="plainArea" rows="3">first,choose table field then configure it.(configure html code will show on there)</textarea>
			<br />
			<br />
			<!--input onclick="ExecuteCommand('bold');" type="button" value="Execute &quot;bold&quot; Command" />
			<input onclick="ExecuteCommand('link');" type="button" value="Execute &quot;link&quot; Command" />
			<br />
			<br />
			<input onclick="CheckDirty();" type="button" value="checkDirty()" />
			<input onclick="ResetDirty();" type="button" value="resetDirty()" /-->
		</div>
	</form>
</body>
</html>
